import AutoImport from "unplugin-auto-import/vite";
import { ElementPlusResolver, VueUseComponentsResolver } from "unplugin-vue-components/resolvers";
import Components from "unplugin-vue-components/vite";
export default plugins => {
	plugins.push(
		AutoImport({
			resolvers: [ElementPlusResolver()],
			imports: ["vue", "vue-router", "@vueuse/core"],
			dirs: ["src/composables", "src/composables/Api"],
			dts: "types/system/auto-imports.d.ts",
			eslintrc: {
				enabled: true,
				globalsPropValue: true
			}
		}),
		Components({
			resolvers: [
				ElementPlusResolver(),
				VueUseComponentsResolver(),

				componentName => {
					if (componentName.startsWith("Icon")) {
						return {
							name: componentName.slice(4),
							from: "@icon-park/vue-next"
						};
					}
				}
			],
			extensions: ["vue", "tsx"],
			dirs: [],
			//组件名称包含目录，防止同名组件冲突
			directoryAsNamespace: true,
			//指定类型声明文件，为true时在项目根目录创建
			dts: "types/system/components.d.ts"
		})
	);
};
